package com.moyuwanjia.service.impl;

import com.moyuwanjia.factory.BeanFactory;
import com.moyuwanjia.mapper.IUserMapper;
import com.moyuwanjia.pojo.User;
import com.moyuwanjia.service.UserService;

/**
 * @author 摸鱼丸加~
 * @create 2022-04-19 11:18
 * @describe <P></P>
 */
public class UserServiceImpl implements UserService {
    private int i = 1;
    // 业务层调用持久层
//    private IUserMapper mapper = new IUserMapperImpl();
//  使用工厂模式解耦的方式，不会导致编译时异
    private IUserMapper mapper =(IUserMapper) BeanFactory.getSingletonBean("userMapper");

    public Integer saveUsers(User user) {
        mapper.save_User(user);
        return i++;
    }
}
